<?php include "classes.inc" ?>
<?php include "constants.inc" ?>
<?php session_start(); ?>
<?php
    if ( isset($_GET['club_id']) == false ) {
    redirect("/clubs/clubs.php");
    }

    $clubId = $_GET['club_id'];
  mysql_connect(DB_SERVER, DB_USER, DB_PWD);
  mysql_select_db(DB_CATALOG);
  $result = mysql_query("select * from club where club_id = ".$clubId);

    $row = mysql_fetch_assoc($result);

    $clubItem = new ClubItem;
    $clubItem->club_id = $row['club_id'];
    $clubItem->clubname = $row['clubname'];
    $clubItem->correspondent = $row['correspondent'];
    $clubItem->correspondent_email = $row['correspondent_email'];
    $clubItem->correspondent_function = $row['correspondent_function'];
    $clubItem->website = $row['website'];
    $clubItem->playdate_adults = $row['playdate_adults'];
    $clubItem->playdate_youth = $row['playdate_youth'];
    $clubItem->site = $row['site'];
    $clubItem->site_address = $row['site_address'];
    $clubItem->email_club = $row['email_club'];
    $clubItem->comment = $row['comment'];

    $result = mysql_query("select u.username, DATE_FORMAT(ch.changed_date,'%e/%m/%Y %k:%i:%s') AS changed_date
      from club_history ch, user u where u.user_id = ch.user_id and ch.club_id = ".$clubId." order by changed_date desc");

    $clubChanges = array();
    while ($row = mysql_fetch_assoc($result)) {
      $clubChange = new ClubChange;
      $clubChange->username = $row['username'];
      $clubChange->changed_date = $row['changed_date'];
      array_push($clubChanges, $clubChange);
    }

  mysql_free_result($result);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Club detail</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../../assets/css/default.css" rel="stylesheet" type="text/css">
</head>

<body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0" class="default">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td>
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="7">
                        <img src="/assets/images/spacer.gif" height="1" width="7" ALT="">
                    </td>
                    <td width="150" align="left"><img src="/assets/images/headerbar_kerst.gif" alt="" ></td>

                </tr>
                <tr>
                    <td colspan="2" height="12"><img src="/assets/images/spacer.gif" alt="" height="12" width="1"></td>
                </tr>
            </table>
        </td>
        <td align="right" valign="top">
    <br/>
<?php
  if ( isset($_SESSION['user']) ) {
    $user = $_SESSION['user'];
?>
      <a href="/logout.php?redirect=/clubs/clubs.php"><img src="/assets/images/24x24/plain/exit.gif" border="0" alt="Log uit"></a>
      <br>&nbsp;<br>
      <span class="headerSmall">User <?=$_SESSION['user']->name?> logged in at <?=$user->login_date?>.</span>

<?php
  } else {
      if ( isset($_POST['username']) && isset($_POST['password']) ) {
          $username = $_POST['username'];
          $password = $_POST['password'];

            mysql_connect(DB_SERVER, DB_USER, DB_PWD);
      mysql_select_db(DB_CATALOG);
            $query = sprintf("SELECT user_id, club_id FROM user WHERE username = '%s' AND password = '%s'",
              mysql_real_escape_string($username), mysql_real_escape_string($password));
      $result = mysql_query($query);
          $num_rows = mysql_num_rows($result);

          if ($num_rows == 1) {
        $user = new User($username);
        $row = mysql_fetch_assoc($result);
        $user->user_id = $row['user_id'];
                $user->club_id = $row['club_id'];
            $_SESSION['user'] = $user;
?>
                <META HTTP-EQUIV="refresh" content="1;URL=<?=HOST?>/clubs/clubs.php">
<?
      } else {
?>
            <span class="headerSmall" style="color:#FFFFCC">Gebruikersnaam '<?=$username?>' en/of paswoord ongeldig, probeer opnieuw.</span>
            <form name="login" action="" method="post" class="login">
        <input id="username" name="username" type="text" size="20" value="gebruikersnaam"
          onFocus="javascript:document.getElementById('username').value=''" />
        <input id="password" name="password" type="password" size="20" value="paswoord"
          onFocus="javascript:document.getElementById('password').value=''" />
        <input type="submit" value="inloggen" />
      </form>
<?php
            }

            mysql_free_result($result);

      } else {
?>
      <form name="login" action="" method="post" class="login">
        <input id="username" name="username" type="text" size="20" value="gebruikersnaam"
          onFocus="javascript:document.getElementById('username').value=''" />
        <input id="password" name="password" type="password" size="20" value="paswoord"
          onFocus="javascript:document.getElementById('password').value=''" />
        <input type="submit" value="inloggen" />
      </form>
<?php
        }
  }
?>
    </td>
    <td>&nbsp;</td>
  </tr>
</table>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td align="left">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td rowspan="2" width="7"><img src="../assets/images/spacer.gif" alt="" height="1" width="7"></td>

          <td valign="top"><img src="../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
          <td nowrap rowspan="2" class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/newsbox.php" target="_top"><span class="tabName">Nieuwsbox</span></a></td>
          <td valign="top"><img src="../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
          <td rowspan="2" width=2><img src="../assets/images/spacer.gif" alt="" height="1" width="2"></td>

          <td valign="top"><img src="../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/tornooien/tornooien.html" target="_top"><span class="tabName">Tornooien</span></a></td>
                    <td valign="top"><img src="../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../assets/images/spacer.gif" alt="" height="1" width="2"></td>

          <td valign="top"><img src="../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/bestuur/bestuur.php" target="_top"><span class="tabName">Bestuur</span></a></td>
                    <td valign="top"><img src="../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../assets/images/spacer.gif" alt="" height="1" width="2"></td>

          <td valign="top"><img src="../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/advalvas/index.html" target="_top"><span class="tabName">Ad Valvas</span></a></td>
                    <td valign="top"><img src="../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../assets/images/spacer.gif" alt="" height="1" width="2"></td>

          <td valign="top"><img src="../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="http://www.frbe-kbsb.be/EloHist/FRBE_Fiche.php" target="_blank"><span class="tabName">ELO</span></a></td>
                    <td valign="top"><img src="../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../assets/images/spacer.gif" alt="" height="1" width="2"></td>

          <td valign="top"><img src="../assets/images/tabcorners/re_FFFFFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="activeSpacer"><img src="../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/clubs/clubs.php" target="_top"><span class="tabName">Clubs</span></a></td>
                    <td valign="top"><img src="../assets/images/tabcorners/re_FFFFFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../assets/images/spacer.gif" alt="" height="1" width="2"></td>

          <td valign="top"><img src="../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/jeugd/index.html" target="_top"><span class="tabName">Jeugd</span></a></td>
                    <td valign="top"><img src="../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../assets/images/spacer.gif" alt="" height="1" width="2"></td>

          <td valign="top"><img src="../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/links/index.php" target="_top"><span class="tabName">Links</span></a></td>
                    <td valign="top"><img src="../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../assets/images/spacer.gif" alt="" height="1" width="2"></td>
        </tr>
        <tr>
          <td class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt=""></td>
          <td class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt=""></td>
          <td class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt=""></td>
          <td class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt=""></td>
          <td class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt=""></td>
          <td class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt=""></td>
          <td class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt=""></td>
          <td class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt=""></td>
          <td class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt=""></td>
          <td class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt=""></td>
          <td class="activeSpacer"><img src="../assets/images/spacer.gif" alt=""></td>
          <td class="activeSpacer"><img src="../assets/images/spacer.gif" alt=""></td>
          <td class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt=""></td>
          <td class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt=""></td>
          <td class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt=""></td>
          <td class="inactiveSpacer"><img src="../assets/images/spacer.gif" alt=""></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td width="100%" bgcolor="#FFFFFF" colspan="13"><img border="0" width="30" src="../assets/images/FFFFFF.gif" height="12" alt=""></td>
  </tr>
</table>

<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0" bgcolor="#FFFFFF">
  <tr>
    <td id="leftFiller" valign="top" height="100%" rowspan="3" bgcolor="#666666">
      <table border="0" cellpadding="0" cellspacing="0" height="100%" width="8px">
        <tr><td>&nbsp;</td></tr>
      </table>
    </td>
    <td id="header" valign="top" width="100%">
      <table border="0" width="100%" cellpadding="3" cellspacing="0" bgcolor="#10425b">
        <tr>
          <td bgcolor="#666666" width="70%">
            <span class="headerLarge">Clubs</span>
            <br>
            <span class="headerMedium">Bestuur, Info</span>
          </td>
          <td bgcolor="#666666" align="right" valign="top">&nbsp;

          </td>
        </tr>
      </table>
      <table align="center" border="0" width="100%" height="90%" cellpadding="0" cellspacing="0" style="border-top:#BCDD10 4px solid;">
        <tr>
          <td>&nbsp;</td>
          <td width="100%" height="20" colspan="2" class="quicklink">
            <a href="clubs.php" target="content">info</a> |
            <a href="clubs.php" target="content">bestuur</a>
          </td>
        </tr>
        <tr>
          <td colspan="2" nowrap bgcolor="#BCDD10" height="4"><img src="../assets/images/spacer.gif" alt="" height="1" width="1"></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td valign="top">
            <table align="left" cellspacing="10" width="100%">
              <tr>
                <td>
                <span class="blackHeaderLarge">Detail club '<?=$clubItem->clubname?>'</span>
                <br>
              </tr>
              <tr>
                <td width="45%" valign="top">
                  <table width="95%" cellspacing="5" class="yellowBox">
                    <tr>
                      <td width="30%"><strong>Nummer</strong></td>
                      <td><?=$clubItem->club_id?></td>
                    </tr>
                      <tr>
                      <td><strong>Naam</strong></td>
                      <td><?=$clubItem->clubname?></td>
                    </tr>
                    
                    <tr>
                      <td><strong>Website</strong></td>
                      <td><?=$clubItem->website?></td>
                    </tr>
                      <tr>
                      <td><strong>Speeldatum volwassenen</strong></td>
                      <td><?=$clubItem->playdate_adults?></td>
                    </tr>
                      <tr>
                      <td><strong>Speeldatum jeugd</strong></td>
                      <td><?=$clubItem->playdate_youth?></td>
                    </tr>
                      <tr>
                      <td><strong>Lokaal</strong></td>
                      <td><?=$clubItem->site?></td>
                    </tr>
                      <tr>
                      <td><strong>Adres</strong></td>
                      <td><?=$clubItem->site_address?></td>
                    </tr>
                      <tr>
                      <td><strong>E-mail</strong></td>
                      <td><?=$clubItem->email_club?></td>
                    </tr>
                      <tr>
                      <td><strong>Commentaar</strong></td>
                      <td><?=$clubItem->comment?></td>
                    </tr>
                  </table>
                </td>
                <td width="45%" valign="top">
                  <table width="95%" cellspacing="5" class="redBox">
                    <tr>
                      <td colspan="2"><strong>Correspondentie</strong></td>
                    </tr>
                      <tr>
                      <td>&nbsp;&nbsp;<strong>Algemeen</strong></td>
                      <td><?=$clubItem->correspondent?>,
                      <a href="mailto:<?=$clubItem->correspondent_email?>"><?=$clubItem->correspondent_email?></a>
                      </td>
                    </tr>
                    <tr>
                      <td>&nbsp;&nbsp;<strong>Penningmeester</strong></td>
                      <td></td>
                    </tr>
                    <tr>
                      <td>&nbsp;&nbsp;<strong>Secretaris</strong></td>
                      <td></td>
                    </tr>
                    <tr>
                      <td>&nbsp;&nbsp;<strong>Tornooileider</strong></td>
                      <td></td>
                    </tr>
                    <tr>
                      <td>&nbsp;&nbsp;<strong>Jeugdleider</strong></td>
                      <td></td>
                    </tr>
                  </table>
                </td>
            </tr>
            <tr>
              <td><a href="clubs.php"><img border="0" src="../../assets/images/24x24/shadow/home.gif">
              <strong style="font-size:11px">Toon clubs</strong></a>
                                <?php
                  if ( isset($user) && $user->club_id == $clubItem->club_id ) {
                                ?>
                                &nbsp;&nbsp;<a href="edit_club_form.php?club_id=<?=$clubItem->club_id?>"><img src="../../assets/images/24x24/shadow/document.gif" border="0">
                                <strong style="font-size:11px">Wijzig de clubgegevens</strong></a>
                                <?php
                                  }
                                ?>
                                <?php
                                  if ( isset($user) && $user->club_id == 100 ) {
                              ?>
                                &nbsp;&nbsp;<a href="edit_club_form.php?club_id=<?=$clubItem->club_id?>"><img src="../../assets/images/24x24/shadow/document.gif" border="0">
                                <strong style="font-size:11px">Wijzig de clubgegevens</strong></a>
                                &nbsp;&nbsp;<a href="delete_club.php?club_id=<?=$clubItem->club_id?>"><img border="0" src="../../assets/images/24x24/shadow/delete2.gif">
                              <strong style="font-size:11px">Verwijder deze club</strong></a>
                                &nbsp;&nbsp;<a href="insert_club_form.php"><img border="0" src="../../assets/images/24x24/shadow/book_blue_add.gif">
                              <strong style="font-size:11px">Schrijf een nieuwe club in</strong></a>
                              <?php
                                  }
                              ?>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>

</body>
</html>
